﻿Imports System.IO

Public MustInherit Class FileSourceArgHandler
    Inherits SimpleListArgHandlerBase

    Private mData As List(Of String)

    Protected MustOverride ReadOnly Property DataFile As String

    Private Function ReadData() As List(Of String)
        Dim ret As New List(Of String)
        Dim reader As StreamReader
        Try
            reader = New StreamReader(Path.Combine("Data", DataFile))
            Do While Not reader.EndOfStream
                Dim line As String = reader.ReadLine
                Dim fileParts() As String = line.Split(New Char() {" "c, CChar(vbTab)})
                If fileParts.Length > 0 Then
                    ret.Add(fileParts(0))
                End If
            Loop
        Catch ex As Exception
        End Try

        Return ret
    End Function

    Public Overrides Function GetValues(obj As RawObject, argument As ArgumentDefinition) As System.Collections.Generic.IEnumerable(Of String)
        If mData Is Nothing Then
            mData = ReadData()
        End If
        Return mData
    End Function
End Class
